/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gmao.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Amine
 */
@Entity
@Table(name = "machine")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Machine.findAll", query = "SELECT m FROM Machine m"),
    @NamedQuery(name = "Machine.findByNom", query = "SELECT m FROM Machine m WHERE m.nom = :nom"),
    @NamedQuery(name = "Machine.findByFabricant", query = "SELECT m FROM Machine m WHERE m.fabricant = :fabricant"),
    @NamedQuery(name = "Machine.findByRef", query = "SELECT m FROM Machine m WHERE m.ref = :ref"),
    @NamedQuery(name = "Machine.findByDateDAchat", query = "SELECT m FROM Machine m WHERE m.dateDAchat = :dateDAchat"),
    @NamedQuery(name = "Machine.findByDesignation", query = "SELECT m FROM Machine m WHERE m.designation = :designation"),
    @NamedQuery(name = "Machine.findByCommentaireEmploye", query = "SELECT m FROM Machine m WHERE m.commentaireEmploye = :commentaireEmploye"),
    @NamedQuery(name = "Machine.findByIdMachine", query = "SELECT m FROM Machine m WHERE m.idMachine = :idMachine")})
public class Machine implements Serializable {
    private static final long serialVersionUID = 1L;

    @Column(name = "nom")
    private String nom;
    
    @Column(name = "fabricant")
    private String fabricant;
    
    @Column(name = "ref")
    private String ref;
    @Column(name = "date_d_achat")
    @Temporal(TemporalType.DATE)
    private Date dateDAchat;
    
    @Column(name = "designation")
    private String designation;
    
    @Size(max = 2147483647)
    @Column(name = "commentaire_employe")
    private String commentaireEmploye;
    
    @Id
    @NotNull
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id_machine")
    private Integer idMachine;
    
    @ManyToMany(mappedBy = "machineList")
    private List<Employe> employeList;
    @OneToMany(mappedBy = "idMachine")
    private List<Pieces> piecesList;
    @OneToMany(mappedBy = "idMachine")
    private List<Intervention> interventionList;
    @OneToMany(mappedBy = "idMachine")
    private List<ArretMachine> arretMachineList;
    @JoinColumn(name = "id_atelier", referencedColumnName = "id_atelier")
    @ManyToOne
    private Atelier idAtelier;

    public Machine() {
    }

    public Machine(Integer idMachine) {
        this.idMachine = idMachine;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getFabricant() {
        return fabricant;
    }

    public void setFabricant(String fabricant) {
        this.fabricant = fabricant;
    }

    public String getRef() {
        return ref;
    }

    public void setRef(String ref) {
        this.ref = ref;
    }

    public Date getDateDAchat() {
        return dateDAchat;
    }

    public void setDateDAchat(Date dateDAchat) {
        this.dateDAchat = dateDAchat;
    }

    public String getDesignation() {
        return designation;
    }

    public void setDesignation(String designation) {
        this.designation = designation;
    }

    public String getCommentaireEmploye() {
        return commentaireEmploye;
    }

    public void setCommentaireEmploye(String commentaireEmploye) {
        this.commentaireEmploye = commentaireEmploye;
    }

    public Integer getIdMachine() {
        return idMachine;
    }

    public void setIdMachine(Integer idMachine) {
        this.idMachine = idMachine;
    }

    @XmlTransient
    public List<Employe> getEmployeList() {
        return employeList;
    }

    public void setEmployeList(List<Employe> employeList) {
        this.employeList = employeList;
    }

    @XmlTransient
    public List<Pieces> getPiecesList() {
        return piecesList;
    }

    public void setPiecesList(List<Pieces> piecesList) {
        this.piecesList = piecesList;
    }

    @XmlTransient
    public List<Intervention> getInterventionList() {
        return interventionList;
    }

    public void setInterventionList(List<Intervention> interventionList) {
        this.interventionList = interventionList;
    }

    @XmlTransient
    public List<ArretMachine> getArretMachineList() {
        return arretMachineList;
    }

    public void setArretMachineList(List<ArretMachine> arretMachineList) {
        this.arretMachineList = arretMachineList;
    }

    public Atelier getIdAtelier() {
        return idAtelier;
    }

    public void setIdAtelier(Atelier idAtelier) {
        this.idAtelier = idAtelier;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMachine != null ? idMachine.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Machine)) {
            return false;
        }
        Machine other = (Machine) object;
        if ((this.idMachine == null && other.idMachine != null) || (this.idMachine != null && !this.idMachine.equals(other.idMachine))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gmao.entities.Machine[ idMachine=" + idMachine + " ]";
    }
    
}
